﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Stote.UControls
{
    public partial class UCStatus : UserControl
    {
        public UCStatus()
        {
            InitializeComponent();
           /* this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.DoubleBuffer, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.Selectable, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            this.SetStyle(ControlStyles.UserPaint, true);*/

            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.Selectable | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true);

            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
            this.Size = new Size(34, 34);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);  // base基类，父类

            // 自已重绘的业务逻辑。（画图）
            Graphics g = e.Graphics;
            g.SmoothingMode = SmoothingMode.AntiAlias;
            Rectangle rect = e.ClipRectangle;   // 切，拿到画图需要的矩形区域。

            Rectangle rect1 = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2);
            //g.DrawEllipse(new Pen(this.ForeColor), rect1);
            g.FillEllipse(new SolidBrush(this.ForeColor), rect1);
        }

        
    }
}
